#include "server_pthread.h"





//添加新的观战者描述符
int epoll_watcher_add(int epwatch, int watcherfd)
{
    playdata * a = nullptr;
    Data &temp = Data::get_Data();
    temp.vol.insert(temp.vol.begin(), new room(a,temp.room_num++));
    struct epoll_event event;
    event.events = EPOLLIN;
    event.data.fd = watcherfd;
    int eret = epoll_ctl(epwatch, EPOLL_CTL_ADD, watcherfd, &event);
    if (eret == -1 )
    {
        cout << "观战者加入失败" << endl;
        return -1;
    }
    return 0;
}

//从epoll中删除要退出或掉线的观战者描述符
int epoll_watcher_del(int epwatch, epoll_event* watcher)
{
    //客户端
    int eret = epoll_ctl(epwatch, EPOLL_CTL_DEL, watcher->data.fd, watcher);
    if(eret<0)
    {
        perror("del error");
        return -1;
    }
    return 0;   
}



//等待用户选择
void wait_chose(playdata *user)
{
    Data &temp = Data::get_Data();
    int ret/* =  调用接收客户端期望的操作的数据 */;
    if (-1 == ret)
    {
        return ;
    }
    // if ()      //如果是创建房间
    // {
        

    // }
    
}

//等待接收用户登录
void wait_Info(playdata* user)
{
    int ret /*=  调用接收客户端登录或注册的数据在对应函数内修改user内的值 */;
    if (ret == -1)
    {
        return ;
    }
    
    wait_chose(user);
    
}

